package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shiminghui
 * @date 2024/10/30 17:28
 * @description: TODO
 */
@RestController
@RequestMapping("/v1/article")
public class ArticleHomeController {

    @Autowired
    private ApArticleService apArticleService;

    /**
     * 加载首页
     *
     * @param dto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(ArticleHomeDto dto) {
        ResponseResult result = apArticleService.loadArticleList(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
        return result;
    }

    /**
     * 加载更多
     *
     * @param dto
     * @return
     */
    @PostMapping("/loadmore")
    public ResponseResult loadmore(ArticleHomeDto dto) {
        ResponseResult result = apArticleService.loadArticleList(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
        return result;
    }

    /**
     * 加载最新
     *
     * @param dto
     * @return
     */
    @PostMapping("/loadnew")
    public ResponseResult loadnew(ArticleHomeDto dto) {
        ResponseResult result = apArticleService.loadArticleList(dto, ArticleConstants.LOADTYPE_LOAD_NEW);
        return result;
    }

}
